package com.nbjtjc.safe.api.cost;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.nbjtjc.safe.annotation.SysLog;
import com.nbjtjc.safe.bean.Result;
import com.nbjtjc.safe.model.cost.CostAccountReg;
import com.nbjtjc.safe.model.cost.CostInjuryClaim;
import com.nbjtjc.safe.service.cost.CostInjuryClaimService;

@RestController
@CrossOrigin("*")
@RequestMapping("/costInjuryClaim")
public class CostInjuryClaimController {
	@Autowired
	private CostInjuryClaimService costInjuryClaimService;


	  @RequestMapping(value = "/addOrUpdate",method = {RequestMethod.POST})
	  @SysLog("添加或更新安全投入受伤索赔主表")
	    public Result add(@RequestBody CostInjuryClaim costInjuryClaim){
	        Result result=new Result();
	        try {
	            result=costInjuryClaimService.add(costInjuryClaim);
	        } catch (Exception e) {
	            e.printStackTrace();
	            result.setFalse(e.getMessage());
	        }
	        return result;
	    }

	  
	  @RequestMapping(value = "/delete",method = {RequestMethod.POST})
	  @SysLog("删除安全投入受伤索赔主表")
	    public Result delete(@RequestBody CostInjuryClaim costInjuryClaim) {
	        Result result=new Result();
	        try {
	            result=costInjuryClaimService.delete(costInjuryClaim);
	        } catch (Exception e) {
	            e.printStackTrace();
	            result.setFalse(e.getMessage());
	        }
	        return result;
	    }

	  @RequestMapping(value = "/find", method = {RequestMethod.POST})
	  public Result find(@RequestBody CostInjuryClaim costInjuryClaim) {
	        Result result = new Result();

	        try {
	            result = costInjuryClaimService.find(costInjuryClaim);
	        } catch (Exception e) {
	            e.printStackTrace();
	            result.setFalse(e.getMessage());
	        }
	        return result;
	    }
	  
	  @RequestMapping(value = "/findDetail", method = {RequestMethod.POST})
	  public Result findDetail(@RequestBody CostInjuryClaim costInjuryClaim) {
	        Result result = new Result();

	        try {
	            result = costInjuryClaimService.findDetail(costInjuryClaim);
	        } catch (Exception e) {
	            e.printStackTrace();
	            result.setFalse(e.getMessage());
	        }
	        return result;
	    }
	  
	  @RequestMapping(value = "/searchByYear", method = {RequestMethod.POST})
	  public Result searchByYear(@RequestBody CostInjuryClaim costInjuryClaim) {
	        Result result = new Result();

	        try {
	            result = costInjuryClaimService.searchByYear(costInjuryClaim.getYear());
	        } catch (Exception e) {
	            e.printStackTrace();
	            result.setFalse(e.getMessage());
	        }
	        return result;
	    }
}
